{Finds center to edge distances along radial lines and displays them in User1.}
var
RoiLeft, RoiTop, RoiWidth, RoiHeight: integer;
x1, y1, x2, y2, count, ppv: integer;
pi, angle, delta, min, max, scale: real;
line, i,nLines, radius, r: integer;
unit: string;
begin
SaveState;
GetRoi(RoiLeft, RoiTop, RoiWidth, RoiHeight);
if RoiWidth=0 then begin
PutMessage('Selection Required.');
exit;
end;
GetScale(scale, unit);
MoveRoi(-RoiLeft, -RoiTop);
KillRoi;
RestoreRoi;
SetForegroundColor(255);
SetBackgroundColor(0);
SetNewSize(RoiWidth, RoiHeight);
MakeNewWindow('Temp');
RestoreRoi;
SetOptions('X-Y Center');
InvertY(false);
Measure;
DrawBoundary;
KillRoi;
x1:=rX[rCount] * scale;
y1:=rY[rCount] * scale;
radius:=sqrt(sqr(x1)+sqr(y1));
r:=sqrt(sqr(RoiWidth-x1)+sqr(y1));
if r > radius then radius := r;
r := sqrt(sqr(RoiWidth-x1) + sqr(RoiHeight - y1));
if r > radius then radius := r;
r := sqrt(sqr(x1) + sqr(RoiHeight - y1));
if r > radius then radius := r;
nLines := GetNumber('Number of Radial Lines:', 36);
pi := 3.14159;
delta := 2.0 * pi / nLines;
angle := 0.0;
ResetCounter;
SetUser1Label('Dist.');
SetOptions('User1');
for line := 1 TO nLines do begin
x2 := x1 + round(radius * cos(angle));
y2 := y1 + round(radius * sin(angle));
MakeLineRoi(x1, y1, x2, y2);
GetPlotData(count, ppv, min, max);
Fill;
i := count;
repeat
i := i - 1;
until (i <= 0) or (PlotData[i] > 0);
rUser1[line] := i;
angle:=angle + delta;
end;
KillRoi;
if scale <> 1 then
for i := 1 to nLines do rUser1[i] := rUser1[i] / scale;
SetCounter(nLines);
RestoreState;
ShowResults;
end;
Macro 'Copy Results to Clipboard with Headers';
begin
SelectWindow('Results');
SetOption; Copy;
end;
Macro 'Export Results with Headers';
begin
SetExport('Measurements');
SetOption; Export('HD80:Image:Results');
end;
macro 'Feret Dimensions [F]';
var
xloc,yloc,width,height:integer;
begin
SetUser1Label('X Feret');
SetUser2Label('Y Feret');
Measure;
GetRoi(xloc,yloc,width,height);
rUser1[rCount]:=width;
rUser2[rCount]:=height;
UpdateResults;
end;
macro 'Bounding Rectangle';
var
xloc,yloc,width,height:integer;
begin
GetRoi(xloc,yloc,width,height);
ShowMessage('xmin=', xloc, '\ymin=', yloc,
'\xmax=', xloc+width-1, '\ymax=', yloc+height-1);
end;
macro 'Calculate Alternate Mean [C]';
{
There are two ways to calculate the mean of a density calibrated image: (1) Convert all the pixels to calibrated values, then calculate the mean; (2) Calculate the mean gray value, then convert this single value to a calibrated value. NIH Image normally uses the first method. This macro calculates the mean using the second method and displays it in the User1 column in the Results window. It also displays the percent difference between the two means in the User2 column.